package com.ch.doudemo.adapter;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;

import com.ch.doudemo.bean.VideoDetailResBean;
import com.ch.doudemo.view.SVideoCommentChildItemview;
import com.ch.doudemo.view.SVideoCommentItemview;

import java.util.ArrayList;
import java.util.List;

public class SVideoCommentChildAdapter extends BaseAdapter {
    private Context context;

    public SVideoCommentChildAdapter(Context context) {
        this.context = context;
    }

    private List<VideoDetailResBean.ChildBody> items = new ArrayList<>();

    public List<VideoDetailResBean.ChildBody> getItems() {
        return items;
    }

    public void setItems(List<VideoDetailResBean.ChildBody> items) {
        this.items = items;
        notifyDataSetChanged();
    }

    @Override
    public int getCount() {
        return items.size();
    }

    @Override
    public Object getItem(int position) {
        return items.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int i, View view, ViewGroup parent) {
        SVideoCommentChildItemview sVideoCommentChildItemview;
        if(null == view){
            sVideoCommentChildItemview = new SVideoCommentChildItemview(context);
        }else{
            sVideoCommentChildItemview = (SVideoCommentChildItemview) view;
        }
        sVideoCommentChildItemview.bind(items.get(i));
        return sVideoCommentChildItemview;
    }
}
